<html>
<head><meta charset="utf-8"><title>diagnostics: duplcated span label · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html">diagnostics: duplcated span label</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="169769511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169769511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169769511">(Jul 06 2019 at 14:38)</a>:</h4>
<p>I see this code in the lexer:</p>
<div class="codehilite"><pre><span></span>let mut err = self.struct_span_fatal(pos, pos, &quot;unterminated raw string&quot;);
err.span_label(self.mk_sp(pos, pos), &quot;unterminated raw string&quot;);
</pre></div>


<p>is it ok that we duplicate the message, or should we just remove the span_label?</p>



<a name="169847926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169847926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169847926">(Jul 08 2019 at 07:52)</a>:</h4>
<p>does <code>git blame</code> reveal anything about why it was added? (or was it there from the beginning?)</p>



<a name="169854863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169854863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169854863">(Jul 08 2019 at 09:49)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119031">@Esteban Küber</span></p>



<a name="169854877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169854877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169854877">(Jul 08 2019 at 09:50)</a>:</h4>
<p>IIRC, the general idea is "no label - bad", so labels are added even if they duplicate the primary message.</p>



<a name="169855286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169855286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169855286">(Jul 08 2019 at 09:56)</a>:</h4>
<p>If there's no label, then the most valuable place on the diagnostic space - text attached to the precise pointer to an error location <code>^^^</code> - becomes vacant.</p>



<a name="169855622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169855622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169855622">(Jul 08 2019 at 10:02)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span>  perhaps we could encode that philosophy ("no label -<br>
 bad") directly into the diagnostic API? E.g., have <code>struct_span_foo</code> take two message arguments, rather than expecting callers to call <code>span_label</code> themselves ?</p>



<a name="169855643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169855643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169855643">(Jul 08 2019 at 10:03)</a>:</h4>
<p>(and having it take two message arguments might encourage diagnostic authors to consider varying the text...)</p>



<a name="169857677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169857677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169857677">(Jul 08 2019 at 10:41)</a>:</h4>
<p>Its something I've toyed with but it does make the API more unwieldy <br>
Well probably end up with that regardless</p>



<a name="169857761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/diagnostics%3A%20duplcated%20span%20label/near/169857761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/diagnostics.3A.20duplcated.20span.20label.html#169857761">(Jul 08 2019 at 10:43)</a>:</h4>
<p>As for the original question petrochencov is spot on. Normally we can benefit by restating with a different wording that can help understanding, but in this case there's very little gramatical wiggle room</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>